package com.mdtx.database.convert;

import java.util.Map;

/**
 * 数据库类型转Java类型映射
 *
 * @author 猫啊
 * @create 2017-09-06 23:05
 **/
public abstract class JavaMapping {

    protected static final String JAVA_INTEGER = "Integer";

    protected static final String JAVA_STRING = "String";

    protected static final String JAVA_DOUBLE = "Double";

    protected static final String JAVA_FLOAT = "Float";

    protected static final String JAVA_LONG = "Long";

    protected static final String JAVA_SHORT = "Short";

    protected static final String JAVA_CHAR = "Character";

    protected static final String JAVA_BYTE = "Byte";

    protected static final String JAVA_BOOLEAN = "Boolean";

    protected static final String JAVA_DATE = "Date";

    protected static final String JAVA_DECIMAL = "BigDecimal";

    protected static Map<String,String> typeMap = null;

    protected Map<String,String> init(){
        if(typeMap == null){
            typeMap = setTypeData();
        }
        return typeMap;
    }

    public String getJavaType(String dbType){
        typeMap = init();
        return typeMap.get(dbType.toLowerCase());
    }

    protected abstract Map<String,String> setTypeData();

    public static void setTypeMap(Map<String, String> typeMap) {
        JavaMapping.typeMap = typeMap;
    }
}
